/**
 * StarInfoNodeUnexplored.java
 *
 * Roslan's Remake of MOO in 3D using Ardor3D
 * (C) 2011 Roslan Amir. All rights reserved.
 */

package com.roslan.games.moo3d.ui.hud;

import com.ardor3d.ui.text.BMFont;
import com.ardor3d.ui.text.BMText;
import com.ardor3d.ui.text.BMText.AutoFade;
import com.ardor3d.ui.text.BMText.AutoScale;
import com.roslan.games.moo3d.data.Star;
import com.roslan.games.moo3d.spatial.StarNode;
import com.roslan.games.moo3d.utils.BMFontLoader;

/**
 * This info node displays the information about the currently selected Star which has not been explored.
 * 
 * @author Roslan Amir
 * @version 1.0 - Aug 9, 2011
 */
public class StarInfoNodeUnexplored extends StarInfoNodeBase {

	/**
	 * 
	 */
	protected final BMText text;

	/**
	 * Constructor.
	 */
	public StarInfoNodeUnexplored() {
		super("Unexplored");
		text = createBMText("Unexplored", "", BMFontLoader.getDefaultFont());
		this.attachChild(text);
	}

	/**
	 * Comment for method.
	 * 
	 * @param name
	 * @param initialText
	 * @param font
	 * @return
	 */
	private BMText createBMText(String name, String initialText, BMFont font) {
		BMText text = new BMText(name, initialText, font, BMText.Align.Center, BMText.Justify.Center);
		text.setFontScale(0.95);
		// text.setDefaultColor(GameData.COLOR_MOO2_BLUE);
		// text.setAutoFadeDistanceRange(nearOpaque, farTransparent);
		text.setAutoFade(AutoFade.CapScreenSize); // CapScreenSize, DistanceRange, FixedPixelSize
		text.setAutoScale(AutoScale.CapScreenSize); // CapScreenSize, FixedScreenSize
		text.setAutoRotate(true);
		text.setTranslation(0.0, -2.0, 0.0);
		return text;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.roslan.games.moo3d.ui.hud.StarInfoNodeBase#update(com.roslan.games.moo3d.spatial.StarNode)
	 */
	@Override
	protected void update(StarNode starNode) {
		text.setText(Star.STAR_DESCRIPTION[starNode.getStar().colorIndex] + "\nRange: " + starNode.range + " parsecs");
		if (!starNode.hasChild(this)) {
			starNode.attachChild(this);
		}
	}

}
